<%--
 *  File:    VarietyInstockChartReport.jsp
 *  @Author: JackYin
 *  Date:    2011/03/15
 *
 *  Copyright (C) 2000 - 2010 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.VarietyInstockChartReport"); 

  //init param
  String strModuleName = "CM";
  String privilegeCode = "R50030";
  String contextPath = request.getContextPath();
%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>VarietyInstockChartReport</title>
<PageFlow:CheckPageFlow pageName="p_nationalsalesreport"/>
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%@ include file="/rpt/ReportURL.inc" %>
<script>
 function page_reformprovince(){
	 var areaidstr = document.cform.areaidstr.options;
	if(1 < areaidstr.length){
		areaidstr[0] = new Option ('ALL',areaidstr[areaidstr.length - 1].value);
		areaidstr[0].selected = true;
		areaidstr[areaidstr.length -1] = null; 
	}
 }
 
 function page_changezone(){
	var bigzoneid = document.cform.bigzoneid.options[document.cform.bigzoneid.selectedIndex].value;
	if(isEmpty(bigzoneid)){
		document.cform.areaidstr.options[0].value = new Option ('-------','');
		document.cform.areaidstr.disabled = true;
		return;
	}else{
		document.cform.areaidstr.disabled = false;
	}
	var datahandler = new  DataHandler() ;
	datahandler.add_params("parentareaid" , bigzoneid, 'Integer');
	datahandler.getResultFromVector("areas" ,"areaname","areaid","document.cform.areaidstr");
	datahandler.add_job("j_nationalsalesreport");
	datahandler.add_function("page_reformprovince()");
	datahandler.runDataHandler();
 }

 function page_go(){
	 getCheckbox();
	 var classvalue = document.cform.classvalue.value;
	 var partareaname = cform.partareaname.options[cform.partareaname.selectedIndex].value;
	 var areaidstr = cform.areaidstr.options[cform.areaidstr.selectedIndex].value;
     var year = document.cform.years.value;
     var month = document.cform.months.value;
     var bigzoneid = document.cform.bigzoneid.value;
    //alert(classvalue+ "  ||  "+partareaname+"  ||  "+areaidstr +"  || "+year+"  || "+month+"  ||  "+bigzoneid);

	var url = "<%= reportURL%>" + "/preview?__report=/ovalreport/NationalSalesReport.rptdesign&sessionid=<%=session.getId()%>&year=" 
	+ year + "&month=" + month+ "&partareaname=" +partareaname + "&classvalue=" +classvalue + "&bigzoneid=" + bigzoneid+"&areaidstr="+areaidstr;
   if(!isEmpty(areaidstr)) url += "&areaidstr=" + areaidstr;
   document.iframe.location.href = url;
    }
 
 function getCheckbox(){
	    var r=document.getElementsByName("levels"); 
	    var values="";
	    for(var i=0;i<r.length;i++){
	      if(r[i].checked){
		      values+=","+r[i].value;
	        }
	     }
	     values=values.substring(1);
	     document.cform.classvalue.value=values;
	    // return values;
	   }
 
 function hiddendisplay(){ 
		var bparea = document.cform.bparea.options[document.cform.bparea.selectedIndex].value;
		if(bparea==10){
	    document.getElementById("bigarea").style.display="block";
	     document.getElementById("partarea").style.display="none";
		}else{
			document.getElementById("bigarea").style.display="none";
			document.getElementById("partarea").style.display="block";
		}
	}
</script>
</head>
<body >
<iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_self">
	<input type="hidden" name="pagename" value="p_nationalsalesreport">
	<input type="hidden" name="actionname">
	<custom:hidden property="processtype"/>
	<custom:hidden property="languagecode" scope="session"/>
	<custom:hidden property="checkstatustemp"/>
	<custom:hidden property="datafrequency"></custom:hidden>
	<custom:hidden property="year"/>
	<custom:hidden property="month"/>
		<custom:hidden property="classvalue"></custom:hidden>
   <tr>
    <td> 
      <table width="100%" border="0" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center" 
style="background:url(<%= contextPath %>/images/<%= strLanguageCode %>/title_2_bg.jpg) repeat-x; " height="36">  
         <tr >
         <% 
         String flag = (String)pageContext.getAttribute("flag");
					java.util.Calendar cal = java.util.Calendar.getInstance();      
					String year = cal.get(Calendar.YEAR)+"";     
					String month = cal.get(Calendar.MONTH)+"";
					if(cal.get(Calendar.MONTH) == 0){
						month = "12";
						year = (cal.get(Calendar.YEAR)-1)+"";
					}  
					if("first".equals(flag)){ 
				%>
        <td width="15%" class="td_right">&nbsp;</td>
          	<td class="td_right" width="6%">年份 <font color="red">*</font>：</td>
            <td width="5%">
            	<custom:selectdic property="years" dictType="Years" command="notnull" value="<%=year %>" label="L_Year1"/>
            </td>
         	<td class="td_right" width="6%">月份 <font color="red">*</font>：</td>
          	<td width="5%">
            	<custom:selectdic property="months" dictType="Months" command="notnull" value="<%=month %>" label="L_Month"/>
            </td>
      <%}else{ %>
      <td class="td_right" width="6%">年份 <font color="red">*</font>：</td>
            <td width="5%">
            	<custom:selectdic property="years" dictType="Years" command="notnull" label="L_Year1"/>
            </td>
         	<td class="td_right" width="6%">月份 <font color="red">*</font>：</td>
          	<td width="5%">
            	<custom:selectdic property="months" dictType="Months" command="notnull" label="L_Month"/>
            </td>
            <%} %>
      
      
         	<td class="td_right" width="6%">区域 <font color="red">*</font>：</td>
				<td width="6%"><select name="bparea" onchange="hiddendisplay();">
				<option value="10">&nbsp;&nbsp;大区</option>
				<option value="20" selected>&nbsp;&nbsp;片区</option>
				</select></td>
			<td>
			<div id="bigarea" style="display:none;">
			<table><tr>
				<td class="td_right" width="6%">大区 ：</td>
				<td width="5%"><custom:select optionInnerTextKey="areaname"
					optionsName="areas" optionValueKey="areaid" property="bigzoneid"
					defaultValue="ALL" defaultValueCost="" onchange="page_changezone()" /></td>
				<td class="td_right" width="6%">省区 ：</td>
				<td width="5%"><select name="areaidstr" disabled="disabled">
					<option value="">----------</option></td>
					</tr></table></div>
					
					
					<div id="partarea" style="display:block;">
			<table><tr>
		
				<td class="td_right" width="6%">片区 ：</td>
				<td width="5%"><custom:selectdic dictType="SmallArea" property="partareaname" /></td>
					<td class="td_right" width="5%">&nbsp;</td>
					<td width="1%">&nbsp;</td>
				
					</tr></table></div>
					</td>
         		<td class="td_right" width="6%">药店级别：</td>
				<td width="8%">
						<input type="checkbox" name="levels" value="A" style="height:15px;border:0px;">A
				<input type="checkbox" name="levels" value="B" style="height:15px;border:0px;">B<br>
				<input type="checkbox" name="levels" value="C" style="height:15px;border:0px;">C
				<input type="checkbox" name="levels" value="D" style="height:15px;border:0px;">D</td>
         	<td width="1%" class="td_right">&nbsp;</td>
         	<td><a href="javascript:page_go()"><img src="<%= contextPath %>/images/<%= strLanguageCode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a></td>
         <td width="10%" class="td_right">&nbsp;</td>
         </tr>
       </table>
    </td>
  </tr>
  </form>
</table>
<iframe src="<%= contextPath %>/Blank.jsp" width="100%" height="87%" name="iframe" frameborder=0 ></iframe>
</body>
</html>